/**
 * creater:han.wen@dhc.com.cn
 * create time:2016-06-06 11:30:54
 * describe:日期选择
 */
APP.controller('DateBoxController', ['$scope', 'ionicDatePicker',
  function ($scope, ionicDatePicker) {

    /***变量声明***/
    $scope.dateHtml = undefined;
    $scope.dateWidget = undefined;
    var dateWidgetInit = undefined;

    /**
     * 初始化函数
     */
    $scope.init = function () {
      $scope.dateHtml = {date: ''};
      $scope.dateWidget = '';
      dateWidgetInit = {
        callback: function (val) {
          $scope.dateWidget = val;
          console.log('您选择了日期控件的时间戳为' + val);
        }
      };
    };


    $scope.openDatePicker = function () {
      ionicDatePicker.openDatePicker(dateWidgetInit);
    };

    //$scope.$watch('dateHtml', function (newVal, oldVal) {
    //  console.log('您选择了h5自带日期的时间为' + newVal.date);
    //});

    /*
     $scope.init();//如果页面缓存则用此方法初始化
     */
    $scope.$on('$ionicView.beforeEnter', function () {
      $scope.init();
    });
  }
]);
